package warmachineroster.presentation.views;

import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.forms.SectionPart;
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.eclipse.ui.forms.widgets.Section;
import org.eclipse.ui.intro.config.IIntroContentProvider;
import org.eclipse.ui.intro.config.IIntroContentProviderSite;


public class RssSectionPart extends SectionPart {

	/**
	 * Create the SectionPart.
	 * 
	 * @param parent
	 * @param toolkit
	 * @param style
	 */
	public RssSectionPart(Composite parent, FormToolkit toolkit, int style) {
		super(parent, toolkit, style);
		createClient(getSection(), toolkit);
	}

	/**
	 * Fill the section.
	 */
	private void createClient(Section section, FormToolkit toolkit) {
		section.setText("New SectionPart");
		final Composite container = toolkit.createComposite(section);
		container.setLayout(new FillLayout());
		WarmabuilderRSSViewer rssViewer = new WarmabuilderRSSViewer();
		rssViewer.init(new IIntroContentProviderSite() {

			@Override
			public void reflow(IIntroContentProvider provider,
					boolean incremental) {
				container.redraw();
			}
		});

		rssViewer
				.createContent(
						"url=http://www.eclipse.org/home/eclipsenews.rss##welcome_items=5##no_news_url=http://www.eclipse.org/community/##no_news_text=Welcome to the Eclipse Community Page",
						container, toolkit);
		section.setClient(container);

	}

}
